﻿using RBAC.MaHaiBo.API.Application.Command.UserCommand;
using RBAC.MaHaiBo.Repository;
using MediatR;
using RBAC.MaHaiBo.Service;

namespace RBAC.MaHaiBo.API.Application.CommandHandlers.UserHandler
{
    public class UserCreateCommandHandlers : IRequestHandler<UserCreateCommand, int>
    {
        IUserService _userService;

        public UserCreateCommandHandlers(IUserService _userService)
        {
            this._userService = _userService;
        }

        public async Task<int> Handle(UserCreateCommand request, CancellationToken cancellationToken)
        {
            return await _userService.AddUser(new Entity.UserInfo() { accountNumber = request.accountNumber, password = request.password, department = request.department, uName = request.uName, uSex = request.uSex, provinceId = request.provinceId, cityId = request.cityId, countyId = request.countyId, address = request.address });
        }
    }

}
